<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>添加角色信息</title>
    <link th:replace="common/header"/>
</head>
<body class="no-skin">
<div th:replace="common/top"/>
<div class="main-container ace-save-state" id="main-container">
    <div th:replace="common/menu"/>
    <div class="main-content">
        <div class="main-content-inner">
            <div th:replace="common/title"/>
            <div class="page-content">
                <div th:replace="common/skin"/>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" action="" name="form" th:action="@{/sys/sysRole/add}"
                              th:method="post" th:object="${sysRole}">
                            <h3 class="header smaller lighter blue"><i class="fa fa-plus" aria-hidden="true"></i>添加角色信息
                            </h3>
                            <div class="row-fluid">
                                <!--PAGE CONTENT BEGINS HERE-->
                                <div class="span6">
                                    <div class="control-group">
                                        <label class="control-label" for="type">是否为公司角色:<span
                                                style="color:red">*</span></label>
                                        <div class="controls">
                                            <select th:field="*{type}" id="type" name="type"
                                                    class="input_fix9" th:value="*{type}">
                                                <option value="">--请选择--</option>
                                                <option value="1">是</option>
                                                <option value="0">否</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="span6">
                                    <span style="color:red"><span th:if="${#fields.hasErrors('type')}"
                                                                  th:errors="*{type}">Name Error</span>&nbsp;</span>
                                </div>
                            </div>
                            <div class="row-fluid" style="display: none" id="company">
                                <!--PAGE CONTENT BEGINS HERE-->
                                <div class="span6">
                                    <div class="control-group">
                                        <label class="control-label" for="companyId">角色所属公司:<span
                                                style="color:red">*</span></label>
                                        <div class="controls">
                                            <select th:field="*{companyId}" id="companyId" name="companyId"
                                                    class="input_fix9" th:value="*{companyId}">
                                                <option value="">--请选择--</option>
                                                <option th:each="company : ${companyInfoList}"
                                                        th:value="${company.id}"
                                                        th:text="${company.companyName}"></option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="span6">
                                    <span style="color:red"><span th:if="${#fields.hasErrors('companyId')}"
                                                                  th:errors="*{companyId}">Name Error</span>&nbsp;</span>
                                </div>
                            </div>
                            <div class="row-fluid">
                                <!--PAGE CONTENT BEGINS HERE-->
                                <div class="span6">
                                    <div class="control-group">
                                        <label class="control-label" for="roleDesc">角色描述:<span
                                                style="color:red">*</span></label>
                                        <div class="controls">
                                            <input type="text" name="roleDesc" id="roleDesc" class="input_fix"
                                                   placeholder="角色描述" th:value="*{roleDesc}" maxlength="50"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="span6">
                                    <span style="color:red"><span id="roleDescErr"
                                                                  th:if="${#fields.hasErrors('roleDesc')}"
                                                                  th:errors="*{roleDesc}">Name Error</span>&nbsp;</span>
                                </div>
                            </div>
                            <div class="row-fluid">
                                <div class="text-center span12">
                                    <button shiro:hasPermission="/sys/sysRole/add" class="btn btn-primary"
                                            type="submit"><i class="fa fa-floppy-o" aria-hidden="true"></i>提交
                                    </button>
                                    <button shiro:hasPermission="/sys/sysRole/add" class="btn btn-danger" type="reset">
                                        <i class="fa fa-times" aria-hidden="true"></i>取消
                                    </button>
                                    <a shiro:hasPermission="/sys/sysRole/getAll" class="btn" href=""
                                       th:href="@{/sys/sysRole/getAll}"><i class="fa fa-reply" aria-hidden="true"></i>返回</a>
                                </div>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <div th:replace="common/footer"/>
</div><!-- /.main-container -->
<div th:replace="common/buttom"/>

<script type="text/javascript">
    $("form").submit(function () {
        $(":submit", this).attr("disabled", "disabled");
    });

    $(function () {
        if ($("#roleDescErr").val() !== "") {
            $("#company").show();
        }
    });

    $("#type").change(function () {
        if (this.value === '1') {
            $("#company").show();
        } else {
            $("#company").hide();
        }
    });
</script>
</body>
</html>
